\(\int \cot ^6(e+f x) (a+b \tan ^2(e+f x))^2 \, dx\) [210]

   Optimal result
   Rubi [A] (verified)
   Mathematica [C] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 23, antiderivative size = 68 \[ \int \cot ^6(e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=-(a-b)^2 x-\frac {(a-b)^2 \cot (e+f x)}{f}+\frac {a (a-2 b) \cot ^3(e+f x)}{3 f}-\frac {a^2 \cot ^5(e+f x)}{5 f} \]

[Out]

-(a-b)^2*x-(a-b)^2*cot(f*x+e)/f+1/3*a*(a-2*b)*cot(f*x+e)^3/f-1/5*a^2*cot(f*x+e)^5/f

Rubi [A] (verified)

Time = 0.10 (sec) , antiderivative size = 68, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.130, Rules used = {3751, 472, 209} \[ \int \cot ^6(e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=-\frac {a^2 \cot ^5(e+f x)}{5 f}+\frac {a (a-2 b) \cot ^3(e+f x)}{3 f}-\frac {(a-b)^2 \cot (e+f x)}{f}-x (a-b)^2 \]

[In]

Int[Cot[e + f*x]^6*(a + b*Tan[e + f*x]^2)^2,x]

[Out]

-((a - b)^2*x) - ((a - b)^2*Cot[e + f*x])/f + (a*(a - 2*b)*Cot[e + f*x]^3)/(3*f) - (a^2*Cot[e + f*x]^5)/(5*f)

Rule 209

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[b, 2]))*ArcTan[Rt[b, 2]*(x/Rt[a, 2])], x] /;
 FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a, 0] || GtQ[b, 0])

Rule 472

Int[(((e_.)*(x_))^(m_.)*((a_) + (b_.)*(x_)^(n_))^(p_))/((c_) + (d_.)*(x_)^(n_)), x_Symbol] :> Int[ExpandIntegr
and[(e*x)^m*((a + b*x^n)^p/(c + d*x^n)), x], x] /; FreeQ[{a, b, c, d, e, m}, x] && NeQ[b*c - a*d, 0] && IGtQ[n
, 0] && IGtQ[p, 0] && (IntegerQ[m] || IGtQ[2*(m + 1), 0] ||  !RationalQ[m])

Rule 3751

Int[((d_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((a_) + (b_.)*((c_.)*tan[(e_.) + (f_.)*(x_)])^(n_))^(p_.), x_Symbol]
 :> With[{ff = FreeFactors[Tan[e + f*x], x]}, Dist[c*(ff/f), Subst[Int[(d*ff*(x/c))^m*((a + b*(ff*x)^n)^p/(c^2
 + ff^2*x^2)), x], x, c*(Tan[e + f*x]/ff)], x]] /; FreeQ[{a, b, c, d, e, f, m, n, p}, x] && (IGtQ[p, 0] || EqQ
[n, 2] || EqQ[n, 4] || (IntegerQ[p] && RationalQ[n]))

Rubi steps \begin{align*} \text {integral}& = \frac {\text {Subst}\left (\int \frac {\left (a+b x^2\right )^2}{x^6 \left (1+x^2\right )} \, dx,x,\tan (e+f x)\right )}{f} \\ & = \frac {\text {Subst}\left (\int \left (\frac {a^2}{x^6}-\frac {a (a-2 b)}{x^4}+\frac {(a-b)^2}{x^2}-\frac {(a-b)^2}{1+x^2}\right ) \, dx,x,\tan (e+f x)\right )}{f} \\ & = -\frac {(a-b)^2 \cot (e+f x)}{f}+\frac {a (a-2 b) \cot ^3(e+f x)}{3 f}-\frac {a^2 \cot ^5(e+f x)}{5 f}-\frac {(a-b)^2 \text {Subst}\left (\int \frac {1}{1+x^2} \, dx,x,\tan (e+f x)\right )}{f} \\ & = -(a-b)^2 x-\frac {(a-b)^2 \cot (e+f x)}{f}+\frac {a (a-2 b) \cot ^3(e+f x)}{3 f}-\frac {a^2 \cot ^5(e+f x)}{5 f} \\ \end{align*}

Mathematica [C] (verified)

Result contains higher order function than in optimal. Order 5 vs. order 3 in optimal.

Time = 0.12 (sec) , antiderivative size = 104, normalized size of antiderivative = 1.53 \[ \int \cot ^6(e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=-\frac {a^2 \cot ^5(e+f x) \operatorname {Hypergeometric2F1}\left (-\frac {5}{2},1,-\frac {3}{2},-\tan ^2(e+f x)\right )}{5 f}-\frac {2 a b \cot ^3(e+f x) \operatorname {Hypergeometric2F1}\left (-\frac {3}{2},1,-\frac {1}{2},-\tan ^2(e+f x)\right )}{3 f}-\frac {b^2 \cot (e+f x) \operatorname {Hypergeometric2F1}\left (-\frac {1}{2},1,\frac {1}{2},-\tan ^2(e+f x)\right )}{f} \]

[In]

Integrate[Cot[e + f*x]^6*(a + b*Tan[e + f*x]^2)^2,x]

[Out]

-1/5*(a^2*Cot[e + f*x]^5*Hypergeometric2F1[-5/2, 1, -3/2, -Tan[e + f*x]^2])/f - (2*a*b*Cot[e + f*x]^3*Hypergeo
metric2F1[-3/2, 1, -1/2, -Tan[e + f*x]^2])/(3*f) - (b^2*Cot[e + f*x]*Hypergeometric2F1[-1/2, 1, 1/2, -Tan[e +
f*x]^2])/f

Maple [A] (verified)

Time = 0.15 (sec) , antiderivative size = 62, normalized size of antiderivative = 0.91

method result size
parallelrisch \(\frac {-3 \cot \left (f x +e \right )^{5} a^{2}+5 a \cot \left (f x +e \right )^{3} \left (a -2 b \right )-15 \left (a -b \right )^{2} \cot \left (f x +e \right )-15 f x \left (a -b \right )^{2}}{15 f}\) \(62\)
derivativedivides \(\frac {\left (-a^{2}+2 a b -b^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )-\frac {a^{2}}{5 \tan \left (f x +e \right )^{5}}-\frac {a^{2}-2 a b +b^{2}}{\tan \left (f x +e \right )}+\frac {a \left (a -2 b \right )}{3 \tan \left (f x +e \right )^{3}}}{f}\) \(79\)
default \(\frac {\left (-a^{2}+2 a b -b^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )-\frac {a^{2}}{5 \tan \left (f x +e \right )^{5}}-\frac {a^{2}-2 a b +b^{2}}{\tan \left (f x +e \right )}+\frac {a \left (a -2 b \right )}{3 \tan \left (f x +e \right )^{3}}}{f}\) \(79\)
norman \(\frac {\left (-a^{2}+2 a b -b^{2}\right ) x \tan \left (f x +e \right )^{5}-\frac {a^{2}}{5 f}-\frac {\left (a^{2}-2 a b +b^{2}\right ) \tan \left (f x +e \right )^{4}}{f}+\frac {a \left (a -2 b \right ) \tan \left (f x +e \right )^{2}}{3 f}}{\tan \left (f x +e \right )^{5}}\) \(87\)
risch \(-x \,a^{2}+2 x a b -x \,b^{2}-\frac {2 i \left (45 a^{2} {\mathrm e}^{8 i \left (f x +e \right )}-60 a b \,{\mathrm e}^{8 i \left (f x +e \right )}+15 b^{2} {\mathrm e}^{8 i \left (f x +e \right )}-90 a^{2} {\mathrm e}^{6 i \left (f x +e \right )}+180 a b \,{\mathrm e}^{6 i \left (f x +e \right )}-60 b^{2} {\mathrm e}^{6 i \left (f x +e \right )}+140 a^{2} {\mathrm e}^{4 i \left (f x +e \right )}-220 a b \,{\mathrm e}^{4 i \left (f x +e \right )}+90 b^{2} {\mathrm e}^{4 i \left (f x +e \right )}-70 a^{2} {\mathrm e}^{2 i \left (f x +e \right )}+140 a b \,{\mathrm e}^{2 i \left (f x +e \right )}-60 b^{2} {\mathrm e}^{2 i \left (f x +e \right )}+23 a^{2}-40 a b +15 b^{2}\right )}{15 f \left ({\mathrm e}^{2 i \left (f x +e \right )}-1\right )^{5}}\) \(217\)

[In]

int(cot(f*x+e)^6*(a+b*tan(f*x+e)^2)^2,x,method=_RETURNVERBOSE)

[Out]

1/15*(-3*cot(f*x+e)^5*a^2+5*a*cot(f*x+e)^3*(a-2*b)-15*(a-b)^2*cot(f*x+e)-15*f*x*(a-b)^2)/f

Fricas [A] (verification not implemented)

none

Time = 0.26 (sec) , antiderivative size = 81, normalized size of antiderivative = 1.19 \[ \int \cot ^6(e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=-\frac {15 \, {\left (a^{2} - 2 \, a b + b^{2}\right )} f x \tan \left (f x + e\right )^{5} + 15 \, {\left (a^{2} - 2 \, a b + b^{2}\right )} \tan \left (f x + e\right )^{4} - 5 \, {\left (a^{2} - 2 \, a b\right )} \tan \left (f x + e\right )^{2} + 3 \, a^{2}}{15 \, f \tan \left (f x + e\right )^{5}} \]

[In]

integrate(cot(f*x+e)^6*(a+b*tan(f*x+e)^2)^2,x, algorithm="fricas")

[Out]

-1/15*(15*(a^2 - 2*a*b + b^2)*f*x*tan(f*x + e)^5 + 15*(a^2 - 2*a*b + b^2)*tan(f*x + e)^4 - 5*(a^2 - 2*a*b)*tan
(f*x + e)^2 + 3*a^2)/(f*tan(f*x + e)^5)

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 133 vs. \(2 (53) = 106\).

Time = 3.95 (sec) , antiderivative size = 133, normalized size of antiderivative = 1.96 \[ \int \cot ^6(e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=\begin {cases} \tilde {\infty } a^{2} x & \text {for}\: e = 0 \wedge f = 0 \\x \left (a + b \tan ^{2}{\left (e \right )}\right )^{2} \cot ^{6}{\left (e \right )} & \text {for}\: f = 0 \\\tilde {\infty } a^{2} x & \text {for}\: e = - f x \\- a^{2} x - \frac {a^{2}}{f \tan {\left (e + f x \right )}} + \frac {a^{2}}{3 f \tan ^{3}{\left (e + f x \right )}} - \frac {a^{2}}{5 f \tan ^{5}{\left (e + f x \right )}} + 2 a b x + \frac {2 a b}{f \tan {\left (e + f x \right )}} - \frac {2 a b}{3 f \tan ^{3}{\left (e + f x \right )}} - b^{2} x - \frac {b^{2}}{f \tan {\left (e + f x \right )}} & \text {otherwise} \end {cases} \]

[In]

integrate(cot(f*x+e)**6*(a+b*tan(f*x+e)**2)**2,x)

[Out]

Piecewise((zoo*a**2*x, Eq(e, 0) & Eq(f, 0)), (x*(a + b*tan(e)**2)**2*cot(e)**6, Eq(f, 0)), (zoo*a**2*x, Eq(e,
-f*x)), (-a**2*x - a**2/(f*tan(e + f*x)) + a**2/(3*f*tan(e + f*x)**3) - a**2/(5*f*tan(e + f*x)**5) + 2*a*b*x +
 2*a*b/(f*tan(e + f*x)) - 2*a*b/(3*f*tan(e + f*x)**3) - b**2*x - b**2/(f*tan(e + f*x)), True))

Maxima [A] (verification not implemented)

none

Time = 0.35 (sec) , antiderivative size = 78, normalized size of antiderivative = 1.15 \[ \int \cot ^6(e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=-\frac {15 \, {\left (a^{2} - 2 \, a b + b^{2}\right )} {\left (f x + e\right )} + \frac {15 \, {\left (a^{2} - 2 \, a b + b^{2}\right )} \tan \left (f x + e\right )^{4} - 5 \, {\left (a^{2} - 2 \, a b\right )} \tan \left (f x + e\right )^{2} + 3 \, a^{2}}{\tan \left (f x + e\right )^{5}}}{15 \, f} \]

[In]

integrate(cot(f*x+e)^6*(a+b*tan(f*x+e)^2)^2,x, algorithm="maxima")

[Out]

-1/15*(15*(a^2 - 2*a*b + b^2)*(f*x + e) + (15*(a^2 - 2*a*b + b^2)*tan(f*x + e)^4 - 5*(a^2 - 2*a*b)*tan(f*x + e
)^2 + 3*a^2)/tan(f*x + e)^5)/f

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 209 vs. \(2 (64) = 128\).

Time = 1.58 (sec) , antiderivative size = 209, normalized size of antiderivative = 3.07 \[ \int \cot ^6(e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=\frac {3 \, a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{5} - 35 \, a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{3} + 40 \, a b \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{3} + 330 \, a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - 600 \, a b \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + 240 \, b^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - 480 \, {\left (a^{2} - 2 \, a b + b^{2}\right )} {\left (f x + e\right )} - \frac {330 \, a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{4} - 600 \, a b \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{4} + 240 \, b^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{4} - 35 \, a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} + 40 \, a b \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} + 3 \, a^{2}}{\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{5}}}{480 \, f} \]

[In]

integrate(cot(f*x+e)^6*(a+b*tan(f*x+e)^2)^2,x, algorithm="giac")

[Out]

1/480*(3*a^2*tan(1/2*f*x + 1/2*e)^5 - 35*a^2*tan(1/2*f*x + 1/2*e)^3 + 40*a*b*tan(1/2*f*x + 1/2*e)^3 + 330*a^2*
tan(1/2*f*x + 1/2*e) - 600*a*b*tan(1/2*f*x + 1/2*e) + 240*b^2*tan(1/2*f*x + 1/2*e) - 480*(a^2 - 2*a*b + b^2)*(
f*x + e) - (330*a^2*tan(1/2*f*x + 1/2*e)^4 - 600*a*b*tan(1/2*f*x + 1/2*e)^4 + 240*b^2*tan(1/2*f*x + 1/2*e)^4 -
 35*a^2*tan(1/2*f*x + 1/2*e)^2 + 40*a*b*tan(1/2*f*x + 1/2*e)^2 + 3*a^2)/tan(1/2*f*x + 1/2*e)^5)/f

Mupad [B] (verification not implemented)

Time = 11.70 (sec) , antiderivative size = 76, normalized size of antiderivative = 1.12 \[ \int \cot ^6(e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=2\,a\,b\,x-b^2\,x-\frac {{\mathrm {cot}\left (e+f\,x\right )}^5\,\left ({\mathrm {tan}\left (e+f\,x\right )}^4\,\left (a^2-2\,a\,b+b^2\right )+\frac {a^2}{5}+{\mathrm {tan}\left (e+f\,x\right )}^2\,\left (\frac {2\,a\,b}{3}-\frac {a^2}{3}\right )\right )}{f}-a^2\,x \]

[In]

int(cot(e + f*x)^6*(a + b*tan(e + f*x)^2)^2,x)

[Out]

2*a*b*x - b^2*x - (cot(e + f*x)^5*(tan(e + f*x)^4*(a^2 - 2*a*b + b^2) + a^2/5 + tan(e + f*x)^2*((2*a*b)/3 - a^
2/3)))/f - a^2*x